package gptma.bo.model.project;

import gptma.bo.model.BaseEntity;
import gptma.bo.model.employee.Employee;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Table(name = "projet")
@AttributeOverride(name = "id", column = @Column(name = "projetId"))
@XmlRootElement
// needed to customize stuff like XMLAttribute
@XmlAccessorType(XmlAccessType.FIELD)
public class Project extends BaseEntity {

	private static final long serialVersionUID = 3600865241876167119L;

	@NotNull
	@Column(name = "codeCRA")
	@XmlAttribute
	private String craCode;

	@NotNull
	@Column(name = "nom")
	private String name;

	@OneToOne
	@JoinColumn(name = "collaborateurId")
	private Employee chief;

	/**
	 * @return the craCode
	 */
	public String getCraCode() {
		return craCode;
	}

	/**
	 * @param craCode
	 *            the craCode to set
	 */
	public void setCraCode(String craCode) {
		this.craCode = craCode;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the chief
	 */
	public Employee getChief() {
		return chief;
	}

	/**
	 * @param chief
	 *            the chief to set
	 */
	public void setChief(Employee chief) {
		this.chief = chief;
	}

}
